package com.lagou.es.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.sql.Connection;
import java.sql.DriverManager;

@Configuration
public class DBConfig {

    @Value("${db.url}")
    private String url;

    @Value("${db.name}")
    private String name ;

    @Value("${db.user}")
    private String user ;

    @Value("${db.password}")
    private String password ;

    @Bean
    public  Connection  getConn(){
        Connection connection = null;
        try {
            Class.forName(this.name);
            connection = DriverManager.getConnection(this.url,this.user,this.password);
        }catch (Exception e){
            e.printStackTrace();
        }
        return  connection;
    }
}
